import axios from '@/utils/request'

// 1.用户登录
export const userLogin = (data) =>{
    return axios({
        url:'/login',
        method:'post',
        data
    })
}
// 2.用户注册
export const userRegister = (data) =>{
    return axios({
        url:'/register',
        method:'post',
        data
    })
}

// 3.根据用户id获取用户详情
export const getUserInfo = (id) => {
    return axios({
      // 这种参数不能通过？拼接，也不能通过params或者data传递
      url: `/user/${id}`,
      // 设置自定义的请求头，我们需要在里面传递token
      headers: { Authorization: localStorage.getItem('toutiaoToken') }
    })
}
// 4.编辑用户信息
export const editUserInfo = (id,data)=>{
    return axios({
        method:'post',
        url:`/user_update/${id}`,
        data
    })
}

// 5 关注用户
 export const followUser = (userid) =>{
     return axios({
         url:`/user_follows/${userid}`
     })
 }
// 6 取消关注
export const unfollowUser = (userid) =>{
    return axios({
        url:`/user_unfollow/${userid}`
    })
}
// 7获取用户关注列表
export const getFollowList = () =>{
    return axios({
        url:'/user_follows'
    })
}
// 8获取用户收藏列表
export const getStarList = ()=>{
    return axios({
        url:'/user_star'
    })
}